#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# @Project : chat_model 
# @File    : schema.py
# @IDE     : PyCharm 
# @Author  :ZH
# @Time    : 2025/1/3 16:40
from datetime import datetime

from pydantic import BaseModel
from typing import Optional, List


class ChatModelListQuery(BaseModel):
    page: Optional[int] = 1
    limit: Optional[int] = 10
    name: Optional[str] = None


class ChatSessionUpdate(BaseModel):
    session_id: int
    session_name: Optional[str] = None
    model_id: Optional[int] = None


class ChatModelListResponseBase(BaseModel):
    id: Optional[int]
    update_date: Optional[datetime]
    model_name_zh: Optional[str]
    model_name: Optional[str]
    firm: Optional[int]
    description: Optional[str]


class ChatModelListResponse(BaseModel):
    code: int
    message: str
    count: int
    data: Optional[List[ChatModelListResponseBase]]


class ChatSessionListQuery(BaseModel):
    page: Optional[int] = 1
    limit: Optional[int] = 10
    name: Optional[str] = None


class ChatSessionCreate(BaseModel):
    session_name: Optional[str] = '新建会话'
    model_id: Optional[int]
    description: Optional[str]


class ChatSessionResponseBase(BaseModel):
    id: Optional[int]
    session_name: Optional[str]
    model_id: Optional[int]
    description: Optional[str]
    update_date: Optional[datetime]


class ChatSessionResponse(BaseModel):
    code: int
    message: str
    data: Optional[ChatSessionResponseBase]


class ChatDialogueListQuery(BaseModel):
    session_id: int
    page: Optional[int] = 1
    limit: Optional[int] = 10


class ChatDialogueListResponseBase(BaseModel):
    id: Optional[int]
    query: Optional[str]
    answer: Optional[str]
    model_name: Optional[str]


class ChatDialogueListResponse(BaseModel):
    code: int
    message: str
    count: Optional[int]
    data: Optional[List[ChatDialogueListResponseBase]]


class ChatQuery(BaseModel):
    session_id: Optional[int]
    query: str
    tool: Optional[list] = None


class ChatResponseBase(BaseModel):
    session_id: Optional[int]
    answer: Optional[str]
    model_id: Optional[int]


class ChatResponse(BaseModel):
    code: int
    message: str
    data: Optional[ChatResponseBase]


class DefaultChatResponse(BaseModel):
    code: int
    message: str


class SessionKnowledgeResponseBaseData(BaseModel):
    id: Optional[int] = None


class SessionKnowledgeResponseBase(BaseModel):
    knowledge_ids: Optional[List[SessionKnowledgeResponseBaseData]] = None
    network: Optional[bool] = None


class SessionKnowledgeResponse(BaseModel):
    code: int
    message: str
    data: SessionKnowledgeResponseBase


class CreateSessionKnowledge(BaseModel):
    session_id: int
    knowledge_ids: List[int] = None
    network: Optional[bool] = None

